package kr.or.kosta.otr.persistence.companyreviewverify;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.annotation.Resource;

import kr.or.kosta.otr.vo.CompanyReviewVerifyVO;
import kr.or.kosta.otr.vo.TrueOrFalseVO;

import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;

@Repository("CompanyReviewVerifyDao")
public class CompanyReviewVerifyDaoImpl implements CompanyReviewVerifyDao{
	@Resource(name="sqlMapClient")
	private SqlMapClient sqlMapClient;
	
	@Override
	public int writeCompanyReviewVerify(CompanyReviewVerifyVO vo)
			throws SQLException {
		return (int) sqlMapClient.insert("CompanyReviewVerify.writeCompanyReviewVerify",vo);
	}

	@Override
	public void deleteCompanyVerify(int companyReviewVerifyId)
			throws SQLException {
		sqlMapClient.delete("CompanyReviewVerify.deleteCompanyVerify", companyReviewVerifyId);
	}

	@Override
	public ArrayList<CompanyReviewVerifyVO> getOneCompanyReviewVerify(
			int companyReviewId) throws SQLException {
		return (ArrayList<CompanyReviewVerifyVO>) sqlMapClient.queryForList("CompanyReviewVerify.getOneCompanyReviewVerify", companyReviewId);
	}

	@Override
	public ArrayList<TrueOrFalseVO> getCompanyReviewVerifyByCompanyId(
			int companyId) throws SQLException {
		ArrayList<TrueOrFalseVO> crv =  (ArrayList<TrueOrFalseVO>) sqlMapClient.queryForList("CompanyReviewVerify.getCompanyReviewVerifyByCompanyId", companyId);
		
		return crv;
	}

	@Override
	public int isExistCompanyReviewVerifyByCompanyId(int companyId)
			throws SQLException {
		// TODO Auto-generated method stub
		return (int) sqlMapClient.queryForObject("CompanyReviewVerify.isExistCompanyReviewVerifyByCompanyId", companyId);
	}

	@Override
	public ArrayList<TrueOrFalseVO> getCompanyReviewVerifyByUserId(String userId)
			throws SQLException {
		// TODO Auto-generated method stub
		return (ArrayList<TrueOrFalseVO>) sqlMapClient.queryForList("CompanyReviewVerify.getCompanyReviewVerifyByUserId",userId);
	}

	@Override
	public ArrayList<TrueOrFalseVO> getCompanyReviewVerifyByInterestReview(
			int reviewId) throws SQLException {
		// TODO Auto-generated method stub
		return (ArrayList<TrueOrFalseVO>) sqlMapClient.queryForList("CompanyReviewVerify.getCompanyReviewVerifyByInterestReview",reviewId);
	}

	@Override
	public int myCompanyReviewVerifyByUserId(String userId) throws SQLException {
		// TODO Auto-generated method stub
		return (int) sqlMapClient.queryForObject("CompanyReviewVerify.myCompanyReviewVerifyByUserId", userId);
	}

	@Override
	public ArrayList<TrueOrFalseVO> getCompanyReviewVerifyByUserIdPage(
			HashMap<String, Object> map) throws SQLException {
		// TODO Auto-generated method stub
		return (ArrayList<TrueOrFalseVO>) sqlMapClient.queryForList("CompanyReviewVerify.getCompanyReviewVerifyByUserIdPage",map);
	}

	@Override
	public int getCompanyReviewVerifyByUserIdTotal(String userId)
			throws SQLException {
		// TODO Auto-generated method stub
		return (int) sqlMapClient.queryForObject("CompanyReviewVerify.getCompanyReviewVerifyByUserIdTotal", userId);
	}

	@Override
	public ArrayList<TrueOrFalseVO> getCompanyReviewVerifyByCompanyIdPage(
			HashMap<String, Object> map) throws SQLException {
		
		return (ArrayList<TrueOrFalseVO>) sqlMapClient.queryForList("CompanyReviewVerify.getCompanyReviewVerifyByCompanyIdPage",map);
	}

	@Override
	public int getCompanyReviewVerifyByCompanyIdTotal(int companyId)
			throws SQLException {
		
		return (int) sqlMapClient.queryForObject("CompanyReviewVerify.getCompanyReviewVerifyByCompanyIdTotal", companyId);
	}
}
